#!/bin/sh
name="maolive-app"
path="/data/app/html"

# if [ $1 = 'prev' ]
# then
# else
# 	path="/home/mao/data/maolivehouse/test/html"
# fi
cd ..
./ECUI/build.sh $name $1

if [ $1 = '' ]
then

	rm -rf $name.tar.gz
	echo ' 请传入环境参数 '
	exit
fi

# 推送到远程服务器
if [ $1 = 'prev' ]
then

scp $name.tar.gz root@39.106.231.156:$path

echo ' 服务器处理 '
ssh root@39.106.231.156 << eeooff
	cd $path
	rm -rf $name/*

	cp $name.tar.gz $name/$name.tar.gz
	cd $name

	tar -zxf $name.tar.gz
	rm -rf $name.tar.gz
	exit 
eeooff
echo Finished: SUCCESS!
echo "添加线上部署日志"
sh ./$name/build-log.sh `pwd`/$name


scp $name.tar.gz root@39.105.203.183:$path

echo ' 服务器处理 '
ssh root@39.105.203.183 << eeooff
	cd $path
	rm -rf $name/*

	cp $name.tar.gz $name/$name.tar.gz
	cd $name

	tar -zxf $name.tar.gz
	rm -rf $name.tar.gz
	exit 
eeooff
echo Finished: SUCCESS!
echo "添加线上部署日志"
sh ./$name/build-log.sh `pwd`/$name


else

scp $name.tar.gz root@39.105.176.253:$path
echo ' 服务器处理 '
ssh root@39.105.176.253 << eeooff
	cd $path
	rm -rf $name/*
	
	cp $name.tar.gz $name/$name.tar.gz
	cd $name

	tar -zxf $name.tar.gz
	rm -rf $name.tar.gz
	exit 
eeooff
echo Finished: SUCCESS!

fi

